package parkManage;

import java.util.Scanner;

/**
 * 停车场信息
 * 
 * 收费记录+总费用
 * 
 * @author 伟❤志
 *
 */
public class ParkModel {

	private String carLisence;// 车牌号
	private int posId;// 车位号
	private int charge;// 费用
	private int cost;// 总费用

	static Scanner scanner = new Scanner(System.in);

	public String getCarLisence() {
		return carLisence;
	}

	public void setCarLisence(String carLisence) {
		this.carLisence = carLisence;
	}

	public int getPosId() {
		return posId;
	}

	public void setPosId(int posId) {
		this.posId = posId;
	}

	public int getCharge() {
		return charge;
	}

	public void setCharge(int charge) {
		this.charge = charge;
	}

	public int getCost() {
		return cost;
	}

	public void setCost(int cost) {
		this.cost = cost;
	}

	/**
	 * 每辆车每个车位收费明细
	 * 
	 * @param parks
	 */
	public void selectAll() {
		for (int i = 0; i < ParkTest.parks.size(); i++) {
			System.out.println("============");
			System.out.println("车牌号：" + ParkTest.parks.get(i).getCarLisence());
			System.out.println("车位号：" + ParkTest.parks.get(i).getPosId());
			System.out.println("收费：" + ParkTest.parks.get(i).getCharge() + "元");
			System.out.println("============");
		}
	}

	/**
	 * 将每个收费信息加入到集合中
	 * 
	 * @param cars
	 * @param positions
	 * @param parks
	 * @param carLisence
	 * @param posId
	 */
	public void addCost(String carLisence, int posId) {
		ParkModel parkModel = new ParkModel();

		parkModel.setCarLisence(carLisence);
		parkModel.setPosId(posId);

		PositionModel po = new PositionModel();
		int i = po.selectPosition(posId);// 车位id

		parkModel.setCharge(ParkTest.positions.get(i).getCost());

		ParkTest.parks.add(parkModel);
	}

	/**
	 * 计算总费用
	 */
	public void totalCost() {
		int sum = 0;
		for (int i = 0; i < ParkTest.parks.size(); i++) {
			sum += ParkTest.parks.get(i).getCost();
		}
		if (ParkTest.parks.size() == 0) {
			System.out.println("未产生费用！");
			return;
		}
		ParkTest.parks.get(ParkTest.parks.size() - 1).setCharge(sum);
	}
}
